package com.hongye.house.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.house.entity.HongyeNoticeEntity;
import com.hongye.house.service.HongyeNoticeService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 后台发送公告表
 *
 * @author lins
 * @email 695565697@qq.com
 * @date 2021-10-14 13:32:23
 */
@RestController
@RequestMapping("house/hongyenotice")
public class HongyeNoticeController {
    @Autowired
    private HongyeNoticeService hongyeNoticeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = hongyeNoticeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{noticeId}")
    public R info(@PathVariable("noticeId") Integer noticeId){
		HongyeNoticeEntity hongyeNotice = hongyeNoticeService.getById(noticeId);

        return R.ok().put("hongyeNotice", hongyeNotice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody HongyeNoticeEntity hongyeNotice){
		hongyeNoticeService.save(hongyeNotice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HongyeNoticeEntity hongyeNotice){
		hongyeNoticeService.updateById(hongyeNotice);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] noticeIds){
		hongyeNoticeService.removeByIds(Arrays.asList(noticeIds));

        return R.ok();
    }

}
